<template>
  <div class="main_app">
    <h1>Hello Options</h1>
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="form-container">
      <el-form-item label="公共脚本" prop="publicScript">
        <el-input v-model="form.publicScript" type="textarea" rows="4" placeholder="请输入公共脚本"></el-input>
      </el-form-item>
      <el-form-item label="自定义脚本" prop="customScript">
        <el-input v-model="form.customScript" type="textarea" rows="4" placeholder="请输入自定义脚本"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'app',
  data() {
    return {
      form: {
        publicScript: '',
        customScript: ''
      },
      rules: {
        publicScript: [
          { required: true, message: '请输入公共脚本', trigger: 'blur' }
        ],
        customScript: [
          { required: true, message: '请输入自定义脚本', trigger: 'blur' }
        ]
      }
    };
  },
  methods: {
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          alert('表单提交成功');
        } else {
          alert('表单校验失败，请检查输入');
          return false;
        }
      });
    }
  }
}
</script>

<style>
.main_app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  width: 600px;
  height: 600px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
}
.form-container {
  width: 100%;
}
</style>
